<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.layui-layer-btn- .layui-layer-btn1{
	background-color: #84c101;
	border: 1px solid #84c101;
	color: #FFF;
}
</style>
</head>
<body>
	
	<fieldset class="layui-elem-field layui-field-title site-title">
		<legend>
			<a name="fixbar" style="font-size: 16px; color: #ce2424;">我的成绩</a>
		</legend>
	</fieldset>
	<table class="layui-hide" id="performance" lay-filter="performance"></table>
	<script type="text/html" id="toolbarDemos">
		<form class="layui-form" id="myForm" method="post" lay-filter="stuform">
		<input type="text" style="display: none;" />
			<div class="layui-inline">
				<label class="layui-form-label" style="width:100px">查询内容:</label>
				<div class="layui-input-block">
					<input type="text" name="search" id="searchvalue" value="${search}" onkeypress="return onKeyPress(event)" class="layui-input" />
				</div>
			</div>
			<div class="layui-inline">
				<button class="layui-btn layui-btn-sm" onclick="searchs()" style="margin-left: 16px"><i class="fa fa-search"></i>查询</button>
			</div>
			<div class="layui-inline">
				<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="performance_add_lay"><i class="fa fa-clipboard"></i>查看证书</button>
			</div>
		</form>
	</script>
	<script type="text/javascript">
		var table = layui.table;
		var option={
			elem:'#performance',
			title:'我的成绩',
			path:'performance',
			addurl:'edit',
			limit: 4000,
			page:false,
			totalRow: true,
			toolbar:'#toolbarDemos',
			defaultToolbar: ['filter', 'exports'],
			cols: [[
				{field: 'information',align:'center', title: '考核项目',templet: function(d){
					return d.information.examination?d.information.examination:"";
				},totalRowText: '合计统计' },
				{field: 'information',align:'center', title: '计分方法',templet: function(d){
					return d.information.scoringmethod?d.information.scoringmethod:"";
				}},
				{field: 'information', title: '说明',templet: function(d){
					return d.information.explain?d.information.explain:"";
				}},
				{field: 'score',align:'center',width:80, title: '分值' ,totalRow: true},
				{field: 'grade',align:'center',width:80, title: '分数' ,templet: function(d){
					return d.grade?d.grade:"未打分";
				} ,totalRow: true}
			]] 
			
			
		}
		var currRow='${param.currRow==null?null:param.currRow}';
		var limit=${param.limit==null?'null':param.limit};
		var page=${param.page==null?'null':param.page};
		var classTable=new LayUiTable(option,currRow,limit,page);
		classTable.init();

		function searchs(){
			classTable.search();
		}
		function empty(){
			classTable.empty();
		} 
		function onKeyPress(event){
			if(event.keyCode==13){
				searchs();
			}
		}
		
		
		table.on('toolbar(performance)', function(obj){
			if(obj.event == 'performance_add_lay'){
				$.post('performance/certificate',function(result) {	
					if(result.success){
						layer.confirm('<!--startprint--><img alt="" src="download?uuid='+result.msg+'" width="100%" height="100%" title="点击重新选择"><!--endprint-->', {
							  title:'证书',
							  area:["862px","572px"],
							  btn: ['<i class="fa fa-clipboard"></i>下载','<i class="fa fa-print"></i>打印','<i class="fa fa-close"></i>关闭'] //按钮
						},function(){
							window.location.href="download?uuid="+result.msg;
							console.info("1");
						},function(){
							debugger;
							var  bdhtml = '<!--startprint--><img alt="" src="download?uuid='+result.msg+'" title="点击重新选择"><!--endprint-->';  
							var  sprnstr = "<!--startprint-->";    //用于截断字符串的内容，截取到指定的图片内容了
							var  eprnstr = "<!--endprint-->";  
							var  prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);  
							     prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));  
//							       var printContent = $("#printConent")[0].innerHTML; //利用jquery获取打印内容;
//							       window.document.body.innerHTML = printContent;
							  if (getExplorer() == "IE") {  
							      pagesetup_null();  
							    }  
							    window.print();  
							return false;
						});
					}else{
						
						 layer.alert(result.msg, {
							  icon: 7,
							  skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
						});
					}
				});
			}
		});
		
	</script>
	<script type="text/javascript">
	
	//获取浏览器类型
	function getExplorer() {  
	    var explorer = window.navigator.userAgent;  
	    //ie   
	    if (explorer.indexOf("MSIE") >= 0) {  
	        return "IE";  
	    }  
	        //firefox   
	    else if (explorer.indexOf("Firefox") >= 0) {  
	        return "Firefox";  
	    }  
	        //Chrome  
	    else if (explorer.indexOf("Chrome") >= 0) {  
	        return "Chrome";  
	    }  
	        //Opera  
	    else if (explorer.indexOf("Opera") >= 0) {  
	        return "Opera";  
	    }  
	        //Safari  
	    else if (explorer.indexOf("Safari") >= 0) {  
	        return "Safari";  
	    }  
	}  
	 
	//IE设置去除页眉页脚  
	function pagesetup_null() {  
	    var hkey_root, hkey_path, hkey_key;  
	    hkey_root = "HKEY_CURRENT_USER";  
	    hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";  
	    try {  
	        var RegWsh = new ActiveXObject("WScript.Shell");  
	        hkey_key = "header";  
	        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");  
	        hkey_key = "footer";  
	        RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");  
	    } catch (e) { }  
	}  	
	</script>
</body>

</html>